Vacuum 2 Click
Vacuum 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Jan 2025.
- Type : ADC/I2C type
Software Support
Example Description
This example demonstrates the use of the Vacuum 2 Click board. It showcases how to initialize the device, perform zero-pressure offset calibration, and measure pressure in Pascals (Pa).
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Vacuum2
Example Key Functions
- vacuum2_cfg_setup Config Object Initialization function.
void vacuum2_cfg_setup(vacuum2_cfg_t *cfg)
Vacuum 2 configuration object setup function.
Vacuum 2 Click configuration object.
Definition vacuum2.h:162
- vacuum2_init Initialization function.
err_t vacuum2_init(vacuum2_t *ctx, vacuum2_cfg_t *cfg)
Vacuum 2 initialization function.
Vacuum 2 Click context object.
Definition vacuum2.h:146
- vacuum2_calib_offset This function calibrates the zero current offset value.
err_t vacuum2_calib_offset(vacuum2_t *ctx)
Vacuum 2 calib offset function.
- vacuum2_read_vout_avg This function reads a desired number of sensor voltage output samples and averages it.
err_t vacuum2_read_vout_avg(vacuum2_t *ctx, uint16_t num_conv, float *vout_avg)
Vacuum 2 read vout avg function.
- vacuum2_read_pressure This function reads the pressure measurement.
err_t vacuum2_read_pressure(vacuum2_t *ctx, int16_t *pressure)
Vacuum 2 read pressure function.
Application Init
Initializes the logger and the Vacuum 2 Click driver. The application then performs zero-pressure offset calibration to ensure accurate pressure measurements. During the calibration, it is crucial to avoid applying pressure to the sensor.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, " Calibrating zero pressure offset in 5 seconds...\r\n" );
log_printf( &logger, " Make sure no pressure is applied to the sensor during the calibration process.\r\n" );
for ( uint8_t cnt = 5; cnt > 0; cnt-- )
{
log_printf( &logger, " %u\r\n", ( uint16_t ) cnt );
Delay_ms ( 1000 );
}
{
log_error( &logger, " Calibrate offset." );
for ( ; ; );
}
log_printf( &logger, " Offset calibration DONE.\r\n\n" );
log_info( &logger, " Application Task " );
}
#define VACUUM2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition vacuum2.h:122
void application_init(void)
Definition main.c:37
#define MIKROBUS_POSITION_VACUUM2
Definition main.c:31
@ VACUUM2_ERROR
Definition vacuum2.h:184
Application Task
Continuously reads the pressure from the sensor and logs the values in Pascals (Pa).
{
int16_t pressure = 0;
{
log_printf( &logger, " Pressure : %d Pa\r\n\n", pressure );
}
}
void application_task(void)
Definition main.c:82
@ VACUUM2_OK
Definition vacuum2.h:183
Note
The measurable pressure range of the sensor is from -2000 Pa to 2000 Pa.
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.